package ch2;

/**
 * Created by 竹韵澜 on 2017/7/16.
 */
public class Test {
    public static void main(String [] args){
        double d = 3.2;
        System.out.println(++d);// “++d”=“d + 1”
        System.out.println(~0b1011);
        //“~”表示java运算符中的位非，“ob”表示二进制
        //先补0,00001011
        //再根据~取反，11110100   得到原码
        //再取反，10001011   得反码
        //+1,10111100   得补码
        //化为十进制，-12

        System.out.printf("%x",0);
        System.out.println();
        System.out.printf("%x",(short)'0');
        System.out.println();

        byte i = (byte)0b00001010;
        byte j = (byte)0b11111010;
        System.out.println(j>>1);
        System.out.println(j>>>1);

        // 自增自减运算符
        // i++ 与 ++i 的区别
        i = 3;
        System.out.println(i++);
        System.out.println(i);
        System.out.println(++i);
        System.out.println(i);
        j = 4;

        //赋值运算符
        System.out.println(i += j);// i = i + j
    }
}
